// 启动
// node serviceDemo.js
const express = require('express')
const app = express()
const vipLogin = require('./data/vip_login.json')

/*为app添加中间件处理跨域请求*/
app.use(function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*')
  res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS')
  res.header('Access-Control-Allow-Headers', 'X-Requested-With')
  res.header('Access-Control-Allow-Headers', 'Content-Type')
  next()
})
// get方式监听/login请求
app.get('/login', (req, res) => {
  //在这里做点什么
  res.send(vipLogin)
})

// 监听3300端口
app.listen(3300, () => {
  console.log('服务器运行在3300')
})
